import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '@/views/Login'
import Layout from '@/views/Layout' // 首页
import Cuisine from '@/views/cuisine' // 菜品
// import Aside from '@/views/aside'
// import { component } from 'vue/types/umd'
// import { Aside } from 'element-ui'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: '/',
    redirect: '/Login'
  },
  {
    path: '/Login',
    name: '登录',
    component: Login
  },
  {
    path: '/Layout',
    name: '主页',
    component: Layout,
    children: [
      {
        path: '/cuisine',
        name: '菜品库',
        component: 'Cuisine',
        meta: { istoken: true } // 判断是否有token
      }
    ]
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL, // 默认路由配置模式 在config里面配置
  routes
})

// 路由前置守卫
router.beforeEach((to, from, next) => {
  next()
})
// 路由后置守卫
router.afterEach((to, from) => {})

export default router
